/**
 * 
 */
package picounit.features.story;

import picounit.Is;
import picounit.When;
import picounit.Will;
import picounit.mocker.VoidAction;

public class WillImpl implements Will {
	private final Is is;
	private final When when;

	public WillImpl(Is is, When when) {
		this.is = is;
		this.when = when;
	}

	@SuppressWarnings("unchecked")
	public <T> T useParameter(T object, VoidAction action) {
		return performAction((Class<T>) object.getClass(), action);
	}

	public <T> T performAction(Class<T> classT, VoidAction action) {
		when.perform(action);

		return is.instanceOf(classT);
	}
}